home *** CD-ROM | disk | FTP | other *** search
/ PC for Alla 2005 May / PC för Alla 0505.iso / fullversioner / realsoft3d / data1.cab / Scripting / scripting / Intro / tabbed.js < prev    next >
Encoding:
Text File  |  2005-04-04  |  2.7 KB  |  88 lines

  1. // creates a tabbed control with number of other gadgets
  2.  
  3. // include javascript classes 
  4. include("oops/r3button.js"); 
  5. include("oops/r3tabbed.js"); 
  6. include("oops/r3cycle.js"); 
  7. include("oops/r3checkb.js"); 
  8. include("oops/r3slider.js"); 
  9. include("oops/r3window.js"); 
  10. include("oops/r3packer.js"); 
  11.  
  12. var tabLabels = ["Buttons", "Sliders", "Check Boxes", "Cycles", 0];
  13. var subPackers = new Array(tabLabels.length);
  14. var window;
  15.  
  16. // ---- create a window with a geometry manager ----
  17.  
  18. toppacker = new r3Packer(R3PA_Orientation, R3PAOF_VERTICAL); 
  19.  
  20. window = new r3Window(R3WGA_Parent, _r3gui, 
  21.                 R3WGA_Left, 200, 
  22.               R3WGA_Top, 100, 
  23.               R3WA_Title, "Window with Packer", 
  24.               R3WA_ReportCloseWindow, TRUE, 
  25.               R3WA_ReportNewSize, TRUE,
  26.               R3WA_Gmanager, toppacker);
  27.  
  28.  
  29. // --- create a tab control with a geometry manager and callback ---- 
  30.  
  31. function tabSelectHook(tab, event, activetab) 
  32.     for(i = 0; i < tabLabels.length; i++) {
  33.         if(i == activetab)
  34.             subPackers[i].SetStealth(FALSE);
  35.         else
  36.             subPackers[i].SetStealth(TRUE);
  37.     }
  38.     tab.FIT(R3WFP_BESTFIT);
  39.  
  40. // packer 
  41. packer = new r3Packer(R3PA_Orientation, R3PAOF_HORIZONTAL); 
  42.  
  43. // tabbed control
  44. tab = new r3Tabbed(R3WGA_Parent, window,
  45.                    R3TABA_Labels, tabLabels,
  46.                    R3RA_Hook, tabSelectHook,
  47.                    R3FRA_GManager, packer);
  48.  
  49.  
  50. // create a sub geometry manager for each tab.
  51.  
  52. for(i = 0; i < tabLabels.length; i++) {
  53.     subPackers[i] = new r3Packer(R3PA_Orientation, R3PAOF_VERTICAL); 
  54.     packer.ADD(R3PAPF_EXPAND | R3PAPF_FILLX | R3PAPF_FILLY, 0, subPackers[i]);
  55. }
  56.  
  57.  
  58. // create some controls for the each tab
  59. for(i = 0; i < 5; i++) { 
  60.     if(button = new r3Button(R3WGA_Parent, tab,  
  61.                   R3GA_Text, "Button " + i))
  62.         subPackers[0].ADD(R3PAPF_EXPAND | R3PAPF_FILLX | R3PAPF_FILLY, 0, button);
  63.  
  64.     if(slider = new r3Slider(R3WGA_Parent, tab,  
  65.                   R3GA_Text, "Slider " + i))
  66.         subPackers[1].ADD(R3PAPF_EXPAND | R3PAPF_FILLX, R3PAAF_ALIGN, slider);
  67.  
  68.     if(checkb = new r3Checkbox(R3WGA_Parent, tab,  
  69.                     R3GA_Text, "Check Box " + i))
  70.         subPackers[2].ADD(R3PAPF_EXPAND, R3PAAF_ALIGN, checkb);
  71.  
  72.     if(cycle = new r3Cycle(R3WGA_Parent, tab,  
  73.                         R3GA_Text, "Cycle " + i,
  74.                         R3MXILTGA_Labels, ["Low", "Medium", "High"]))
  75.         subPackers[3].ADD(R3PAPF_EXPAND | R3PAPF_FILLX, R3PAAF_ALIGN, cycle);
  76.  
  77. // insert tab into the window's gmanager
  78. toppacker.ADD(R3PAPF_EXPAND | R3PAPF_FILLX | R3PAPF_FILLY, 0, tab);
  79.  
  80. // set default tab
  81. tabSelectHook(tab, 0, 0);
  82.  
  83. window.FIT(R3WFP_BESTFIT); 
  84. window.REALIZE();
  85.